goog.provide('czk.ui.tab.Tabbox');

goog.require('goog.dom');
goog.require('goog.dom.TagName');

goog.require('czk.ui.ZKComponent');

/**
 * @constructor
 * @extends {czk.ui.ZKComponent}
 */
czk.ui.tab.Tabbox = function() {
  goog.base(this);
};
goog.inherits(czk.ui.tab.Tabbox, czk.ui.ZKComponent);

/**
 * Constants for event names.
 * @enum {string}
 */
czk.ui.tab.Tabbox.EventType = {
  SELECT: 'select'
};

czk.ui.tab.Tabbox.prototype.tabs = null;
czk.ui.tab.Tabbox.prototype.tabPanels = null;

czk.ui.tab.Tabbox.prototype.createDom = function() {
  var dh = this.getDomHelper();
  var el = dh.createDom(goog.dom.TagName.DIV, {
    'className': 'tab'
  });

  this.setElementInternal(el);
};

czk.ui.tab.Tabbox.prototype.select = function() {
  this.tabPanels.select(this.tabs.selectIndex);

};

/** @inheritDoc */
czk.ui.tab.Tabbox.prototype.enterDocument =
    function() {
      goog.base(this, 'enterDocument');
      this.getHandler().listen(this.tabs, czk.ui.tab.Tabbox.EventType.SELECT,
          this.select, false, this);
      this.select();

    };

czk.ui.tab.Tabbox.create = function() {
  return new czk.ui.tab.Tabbox();
};
